package com.hz.api.admin.stream.util;

import java.util.Random;

public class IdWorkerUtils {

    public static Long getIdWorker(){
        Random random = new Random();
        String randomStr = String.valueOf(random.nextInt(9999));
        String timeStamp = String.valueOf(System.currentTimeMillis());
        return Long.parseLong(randomStr + timeStamp);
    }

    public static String getIdWorkerStr(int length){
        String charPool = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < length; i++) {
            char randomChar = charPool.charAt(random.nextInt(charPool.length()));
            sb.append(randomChar);
        }
        return sb.toString();
    }
}
